<template>
	<div class="table">
		<div class="tableHead tableRow">
			<div class="tableCell" style="width: 10%">编号</div>
			<div class="tableCell" style="width: 50%">申报企业</div>
			<div class="tableCell" style="width: 20%">是否申报成功</div>
			<div class="tableCell" style="width: 20%; border-right: 0">是否兑现</div>
		</div>
		<div class="tableRow" v-for="apply in applyList" :key="apply.applyId">
			<div class="tableCell" style="width: 10%"> {{ no }} </div>
			<div class="tableCell" style="width: 50%"> {{ apply.companyName }} </div>
			<div class="tableCell" style="width: 20%" :style="'color: ' + formatApplyStatusOption(apply.applyStatus).color">
				{{ formatApplyStatusOption(apply.applyStatus).label }}
			</div>
			<div class="tableCell" style="width: 20%" :style="'color: ' + formatredemptionStatus(apply.redemptionStatus).color">
				{{ formatredemptionStatus(apply.redemptionStatus).label }}
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		name: "applyList",
		props: {
			applyList: {
				type: Array,
				default: []
			},
			no: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				redemptionStatusOptions: [{ 
					value: 1,
					// label: '待审核'
					label: '兑现中'
				}, {
					value: 2,
					// label: '审核中'
					label: '兑现中'
				}, {
					value: 3,
					// label: '审核通过',
					label: '是',
					color: '#10a217'
				}, {
					value: 4,
					// label: '审核不通过'
					label: '否'
				},{
					value: null,
					label: '-'
				}],//兑现状态
				applyStatusOptions: [{ 
					value: 1,
					// label: '待审核'
					label: '申报中'
				}, {
					value: 2,
					// label: '审核中'
					label: '申报中'
				}, {
					value: 3,
					// label: '审核通过',
					label: '是',
					color: '#10a217'
				}, {
					value: 4,
					// label: '审核不通过'
					label: '否'
				},
				{
					value: null,
					label: '-'
				}]// 申报状态
			}
		},
		methods: {
			/**
			 * 格式化显示兑现状态
			 * @param redemptionStatus 要格式化显示的兑现状态
			 */
			formatredemptionStatus: function (redemptionStatus) {
				let ns = this
				for(let i = 0; i < ns.redemptionStatusOptions.length; i++) {
					if(ns.redemptionStatusOptions[i].value == redemptionStatus) {
						return ns.redemptionStatusOptions[i]
					}
				}
				return {label: ''}
			},
			/**
			 * 格式化显示申报状态
			 * @param applyStatus 要格式化的申报状态
			 * @return {{label, value}|*|{label: string}} 格式化后的申报状态
			 */
			formatApplyStatusOption: function (applyStatus) {
				let ns = this
				for(let i = 0; i < ns.applyStatusOptions.length; i++) {
					if(ns.applyStatusOptions[i].value == applyStatus) {
						return ns.applyStatusOptions[i]
					}
				}
				return {label: ''}
			}
		}
	}
</script>

<style scoped>
	.table {
		color: #666666;
		font-size: 13px;
	}

	.table .tableHead {
		background-color: #f4f4f4;
		border-top: 1px;
	}

	.table .tableRow {
		display: flex;
		justify-content: space-between;
		border: 1px solid #eeeeee;
		border-top: 0;
	}

	.table .tableRow .tableCell {
		padding: 10px 20px;
		text-align: left;
		border-right: 1px solid #eeeeee;
	}
</style>
